#include <stdio.h>

// 将十进制数转换为二进制
void decimalToBinary(int n)
{
    int binaryNum[32];
    int i = 0;
    while (n > 0)
    {
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }
    for (int j = i - 1; j >= 0; j--)
    {
        printf("%d", binaryNum[j]);
    }
}

// 将十进制数转换为八进制
void decimalToOctal(int n)
{
    int octalNum[100];
    int i = 0;
    while (n > 0)
    {
        octalNum[i] = n % 8;
        n = n / 8;
        i++;
    }
    for (int j = i - 1; j >= 0; j--)
    {
        printf("%d", octalNum[j]);
    }
}

// 将十进制数转换为十六进制
void decimalToHexadecimal(int n)
{
    char hexaDecimalNum[100];
    int i = 0;
    while (n != 0)
    {
        int temp = 0;
        temp = n % 16;
        if (temp < 10)
        {
            hexaDecimalNum[i] = temp + 48;
        }
        else
        {
            hexaDecimalNum[i] = temp + 55;
        }
        i++;
        n = n / 16;
    }
    for (int j = i - 1; j >= 0; j--)
    {
        printf("%c", hexaDecimalNum[j]);
    }
}

int main()
{
    int decimalNum;
    printf("Enter a decimal number: ");
    scanf("%d", &decimalNum);

    printf("Binary: ");
    decimalToBinary(decimalNum);

    printf("\nOctal: ");
    decimalToOctal(decimalNum);

    printf("\nHexadecimal: ");
    decimalToHexadecimal(decimalNum);

    return 0;
}